import 'package:abc/view/icon_utils.dart';
import 'package:abc/view/net_load_img.dart';
import 'package:abc/view/video_model.dart';
import 'package:flutter/material.dart';

/// 视频标签工具类
class VideoTagUtils {
  /// 默认标签高度
  static const double _defaultTagHeight = 17.0;

  /// 根据视频信息生成支付类型标签
  ///
  /// [video] 视频模型
  /// [tagHeight] 标签高度，默认为17.0
  /// 返回对应的标签Widget
  static Widget buildPayTypeIcon(VideoModel video, {double? tagHeight}) {
    final height = tagHeight ?? _defaultTagHeight;

    /// 动漫显示是否完结
    bool isAnime = video.isAnime;
  print('VideoTagUtils: 动漫标签 - isAnime=${video.isAnime};name=${video.name}');
    if (isAnime) {
      
      bool isOver = video.isAnimeOver;
    
      return  Container(
          padding: EdgeInsets.symmetric(horizontal: 7, vertical: 2),
          decoration: BoxDecoration(
            color: Color(0xFFF85046),
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(10),
              topLeft: Radius.circular(10),
              topRight: Radius.circular(8),
            ),
          ),
          child: Center(
            child: Text(
              isOver ? '已完结' : '未完结',
              style: TextStyle(
                color: Colors.white,
                fontSize: 11,
                fontWeight: FontWeight.w400,
                height: 1
              ),
            ),
          ),
        
      );
     
    }

    //1金币 2 会员 3 免费 4 用户等级
    if (video.payType == 3) {
      return const SizedBox();
    }

    bool isVip = video.payType == 2;
    bool isLevel = video.payType == 4;
    bool isCoin = video.payType == 1;

    if (isVip) {
      return Container(
        padding: EdgeInsets.all(1),
        decoration: BoxDecoration(
          color: Color(0XFFE0AB68),
          borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(10),
            topLeft: Radius.circular(10),
            topRight: Radius.circular(8),
          ),
        ),
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 10, vertical: 1),
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [Color(0xFFFFDB83), Color(0xFFFFA335)],
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
            ),
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(10),
              topLeft: Radius.circular(10),
            ),
          ),
          child: Center(
            child: Text(
              'VIP',
              style: TextStyle(
                color: Color(0xFF733300),
                fontSize: 11,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
        ),
      );
    }

    if (isLevel) {
      return Container(
        padding: EdgeInsets.all(1),
        decoration: BoxDecoration(
          color: Color(0XFFFF9C96),
          borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(10),
            topLeft: Radius.circular(10),
          ),
        ),
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 10, vertical: 1),
          decoration: BoxDecoration(
            color: Color(0xFFF85046),
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(10),
              topLeft: Radius.circular(10),
              topRight: Radius.circular(8),
            ),
          ),
          child: Center(
            child: Text(
              'Lv${video.level}',
              style: TextStyle(
                color: Color(0xFFFFDFDD),
                fontSize: 11,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
        ),
      );
    }

    if (isCoin) {
      // print('VideoTagUtils: 金币标签 - price=${video.price}, height=$height');
      return Container(
        padding: EdgeInsets.all(1),
        decoration: BoxDecoration(
          color: Color(0XFF9E97EC),
          borderRadius: BorderRadius.only(
            bottomLeft: Radius.circular(10),
            topLeft: Radius.circular(10),
          ),
        ),
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: 10, vertical: 1),
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [Color(0xFFA877F4), Color(0xFF5650D6)],
              begin: Alignment.topLeft,
              end: Alignment.bottomRight,
            ),
            borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(10),
              topLeft: Radius.circular(10),
              topRight: Radius.circular(8),
            ),
          ),
          child: Center(
            child: Text(
              '${video.price}金币',
              style: TextStyle(
                color: Color(0xFFD9D5FF),
                fontSize: 11,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
        ),
      );
    }

    return const SizedBox();
  }

  static Widget buildPayTypeIconUI3(VideoModel video, {double? tagHeight}) {
    final height = tagHeight ?? _defaultTagHeight;
    if (video.payType == 3) {
      return const SizedBox();
    }

    bool isVip = video.payType == 2;
    bool isLevel = video.payType == 4;
    bool isCoin = video.payType == 1;

    if (isVip || isLevel || isCoin) {
      return Container(
        width: height * 3.01,
        height: height,
        alignment: Alignment.center,
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            colors: [Color(0XFFA877F4), Color(0XFF5650D6)],
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
          ),
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(20),
            topRight: Radius.circular(20),
            bottomLeft: Radius.circular(20),
          ),
        ),
        child: Text(
          isVip
              ? 'VIP'
              : (isLevel ? "LV${video.level}" : "${video.discount}金币"),
          style: const TextStyle(
            fontSize: 11,
            height: 1.2,
            fontWeight: FontWeight.w600,
            color: Color(0xFFD9D5FF),
          ),
        ),
      );
    }

    return const SizedBox();
  }
}
